#ifndef RES_SOUND_H
#define RES_SOUND_H
#include <string>

#include "boost/shared_ptr.hpp"

#include "SFML/Audio.hpp"


#define SOUND_POINT 0x01
#define SOUND_GLOBAL 0x02
#define SOUND_REPEAT 0x04

class ResSound : public sf::Sound
{
public:
    ResSound(std::string filename, char flags, sf::Vector2i position, float volume = 1.0f, float pitch = 1.0f);

    void update(float delta);

    void smoothPause(float duration);
    void instantPause();

    void smoothStop(float duration);
    void instantStop();

    void smoothPlay(float duration);
    void instantPlay();

    float   getVolumeMax() const;
    void    setVolumeMax(float volumeMax);

    sf::Vector2i getPosition() const;
    void setPosition(sf::Vector2i position);

    std::string getFileName() const;
    char        getFlags() const;

private:
    sf::SoundBuffer soundBuffer; //Sound buffer for sf::Sound
    float           volumeMax; //Maximum volume for this sound
    sf::Vector2i    position;
    float           smoothTime;
    float           smoothTimeRemaining;
    bool            todoPause; //true if it should be paused
    bool            todoStop; //true if it should be stopped
    bool            todoPlay; //true if it should be played
    std::string     fileName;
    unsigned char   soundFlags; //Object flags
    enum            soundFlags {
        SoundPoint              = 0x01,
        SoundGlobal             = 0x02,
        SoundRepeat             = 0x04
    };
};

typedef boost::shared_ptr<ResSound> ResSoundPtr;

#endif /* ITEMDATA_H*/